/*
 * block_handler.h
 *
 * Copyright 2011 Pieter Agten
 *
 * This file is part of Yarf.
 *
 * Yarf is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Yarf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Yarf.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   block_handler.h
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   23 sep 2011
 * @brief  The block handler component is responsible for executing blocks 
 *         placed into the planning queue by the planner component.
 */

#ifndef BLOCK_HANDLER_H
#define BLOCK_HANDLER_H

#include <stdbool.h>

/**
 * Initializes the block handler component.
 *
 * Needs to be called only once, on boot. Note that this does not actually
 * start the block handler thread.
 *
 * @see block_handler_start
 */
void block_handler_init(void);

/**
 * Starts the block handler thread.
 * 
 * Note that the block handler thread stops automatically when the planning
 * queue is empty.
 */
void block_handler_start(void);

/**
 * Pauses the block handler thread.
 * 
 * This stops the block handler procedure from being executed, so no more steps
 * will be taken until the thread is restarted. Note however that this will not
 * cancel the current block. So the block handler thread will continue with the
 * current block when it is restarted.
 */
void block_handler_pause(void);

/**
 * Stops the block handler thread.
 * 
 * This stops the block handler procedure from being executed and cancels the 
 * current block. The block handler thread will continue with the next block in
 * the planning queue when it is restarted.
 */
void block_handler_stop(void);

/**
 * Returns whether the block handler thread is running.
 * 
 * @return Whether the block handler thread is running.
 */
bool block_handler_running(void);


#endif //BLOCK_HANDLER_H
